package com.netty.server.handler;

import com.netty.server.handler.base.HandlerFactory;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;

/**
 * @author: 王霄
 * @date: 2022/1/20 13:44
 **/
public class TankChannelInitializer extends ChannelInitializer<Channel> {

    private final HandlerFactory factory;

    public TankChannelInitializer(HandlerFactory factory) {
        this.factory = factory;
    }

    @Override
    protected void initChannel(Channel channel) {
        channel.pipeline()
                .addLast(factory.newIdleStateHandler())
                .addLast(factory.newLoginHandler())
                .addLast(factory.newBaseDecoder())
                .addLast(factory.newByteCmdHandler())
                .addLast(factory.newClientAuthHandler())
                .addLast(factory.newResCmdHandler())
                .addLast(factory.newRegisterHandler())
                .addLast(factory.newTankFrameDecoder());
    }
}
